package com.putable.cgw.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.UIManager;

/**
 * Ehh real basic applet I guess.
 * 
 * Will change the panels to allow paint ect.
 * @author Evan
 *
 */
public class BaseApplet extends JApplet {

	
	private static final long serialVersionUID = 1L;
	
	private JMenu file;
	private JMenuBar mainMenuBar;
	private JPanel leftPanel;
	private JPanel rightPanel;
	private JSplitPane background;
	private JMenuItem jMenuItem2;
	private JMenuItem jMenuItem1;

	{
		try {
			UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Look and feel failed");
		}
	}

	private Dimension windowSize = new Dimension(900, 550);
	
	public void init() {

		try {
			// Set main layout
			BorderLayout thisLayout = new BorderLayout();
			getContentPane().setLayout(thisLayout);
			// Set size
			this.setSize(900, 550);

			// Background split pane, holds both panels
			background = new JSplitPane();
			getContentPane().add(background, BorderLayout.CENTER);
			background
					.setBorder(BorderFactory.createCompoundBorder(null, null));
			background.setBackground(new Color(106, 106, 106));
			background.setDividerLocation((int) (windowSize.width * 0.20));
			background.setDividerSize(5);
			
			rightPanel = new JPanel();
			background.add(rightPanel, JSplitPane.RIGHT);
			rightPanel.setPreferredSize(new Dimension((int) (windowSize.width * 0.75), windowSize.height));
			rightPanel.setBackground(new Color(192, 192, 192));

			leftPanel = new JPanel();
//			BorderLayout leftPanelLayout = new BorderLayout();
//			leftPanel.setLayout(lefPanelLayout);
			background.add(leftPanel, JSplitPane.LEFT);
			leftPanel.setPreferredSize(new Dimension((int) (windowSize.width * 0.25), windowSize.height));
			leftPanel.setBackground(new Color(157, 0, 0));

			// Main menu bar
			mainMenuBar = new JMenuBar();
			setJMenuBar(mainMenuBar);

			// Drop down menu
			file = new JMenu();
			mainMenuBar.add(file);
			file.setText("File");

			// items ect.
			jMenuItem1 = new JMenuItem();
			file.add(jMenuItem1);
			jMenuItem1.setText("An item");

			jMenuItem2 = new JMenuItem();
			file.add(jMenuItem2);
			jMenuItem2.setText("Anoter item");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
